package com.general.framework.core.enums;

import com.general.framework.core.lang.Strings;

import java.util.Objects;

/**
 * 操作状态
 *
 * @author leejean
 */
public enum BusinessStatus {

    SUCCESS(1, "成功"),
    FAIL(0, "失败");

    private int code;

    private String desc;

    BusinessStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static String getDesc(Integer code) {
        for (BusinessStatus thisEnum : BusinessStatus.values()) {
            if (Objects.equals(thisEnum.code, code)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }
}
